package com.ny.controller;




import com.ny.entity.User;
import com.ny.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    private UserService userService;


    @PostMapping("/login")
    public String login(@RequestParam String username, @RequestParam String password) {
        // 这里为了简化，我们直接调用数据库查询用户
        // 在实际项目中，你可能需要处理密码的加密和解密
        User user = userService.findUserByUsername(username);
        if (user != null && user.getPassword().equals(password)) {
            return "登录成功";
        } else {
            return "用户名或密码错误";
        }
    }

}